home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxcspace.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.7 KB  |  254 lines

  1. /* Copyright (C) 1996, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxcspace.h,v 1.4 2000/09/19 19:00:35 lpd Exp $ */
  20. /* Implementation of color spaces */
  21. /* Requires gsstruct.h */
  22.  
  23. #ifndef gxcspace_INCLUDED
  24. #  define gxcspace_INCLUDED
  25.  
  26. #include "gscspace.h"        /* client interface */
  27. #include "gsccolor.h"
  28. #include "gscsel.h"
  29. #include "gxfrac.h"        /* for concrete colors */
  30.  
  31. /* Define opaque types. */
  32.  
  33. #ifndef gx_device_color_DEFINED
  34. #  define gx_device_color_DEFINED
  35. typedef struct gx_device_color_s gx_device_color;
  36. #endif
  37.  
  38. #ifndef gx_device_DEFINED
  39. #  define gx_device_DEFINED
  40. typedef struct gx_device_s gx_device;
  41. #endif
  42.  
  43. /* Color space types (classes): */
  44. /*typedef struct gs_color_space_type_s gs_color_space_type; */
  45. struct gs_color_space_type_s {
  46.  
  47.     gs_color_space_index index;
  48.  
  49.     /*
  50.      * Define whether the space can be the base space for an Indexed
  51.      * color space or the alternate space for a Separation or DeviceN
  52.      * color space.
  53.      */
  54.  
  55.     bool can_be_base_space;
  56.     bool can_be_alt_space;
  57.  
  58.     /*
  59.      * Define the true structure type for this variant of the color
  60.      * space union.
  61.      */
  62.  
  63.     gs_memory_type_ptr_t stype;
  64.  
  65.     /* ------ Procedures ------ */
  66.  
  67.     /*
  68.      * Define the number of components in a color of this space.  For
  69.      * Pattern spaces, where the number of components depends on the
  70.      * underlying space, this value is -1 for colored Patterns,
  71.      * -N-1 for uncolored Patterns, where N is the number of components
  72.      * in the base space.
  73.      */
  74.  
  75. #define cs_proc_num_components(proc)\
  76.   int proc(P1(const gs_color_space *))
  77. #define cs_num_components(pcs)\
  78.   (*(pcs)->type->num_components)(pcs)
  79.     cs_proc_num_components((*num_components));
  80.  
  81.     /*
  82.      * Return the base or alternate color space underlying this one.
  83.      * Only defined for Indexed, Separation, DeviceN, and
  84.      * uncolored Pattern spaces; returns NULL for all others.
  85.      */
  86.  
  87. #define cs_proc_base_space(proc)\
  88.   const gs_color_space *proc(P1(const gs_color_space *))
  89. #define cs_base_space(pcs)\
  90.   (*(pcs)->type->base_space)(pcs)
  91.     cs_proc_base_space((*base_space));
  92.  
  93.     /*
  94.      * Test whether this color space is equal to another one of the same
  95.      * type.  Spurious 'false' answers are OK if the real test is too much
  96.      * work, but spurious 'true' answers are not.
  97.      */
  98.  
  99. #define cs_proc_equal(proc)\
  100.   bool proc(P2(const gs_color_space *, const gs_color_space *))
  101.     cs_proc_equal((*equal));
  102.  
  103.     /* Construct the initial color value for this space. */
  104.  
  105. #define cs_proc_init_color(proc)\
  106.   void proc(P2(gs_client_color *, const gs_color_space *))
  107. #define cs_init_color(pcc, pcs)\
  108.   (*(pcs)->type->init_color)(pcc, pcs)
  109. #define cs_full_init_color(pcc, pcs)\
  110.   ((pcc)->pattern = 0, cs_init_color(pcc, pcs))
  111.     cs_proc_init_color((*init_color));
  112.  
  113.     /* Force a client color into its legal range. */
  114.  
  115. #define cs_proc_restrict_color(proc)\
  116.   void proc(P2(gs_client_color *, const gs_color_space *))
  117. #define cs_restrict_color(pcc, pcs)\
  118.   ((pcs)->type->restrict_color(pcc, pcs))
  119.     cs_proc_restrict_color((*restrict_color));
  120.  
  121.     /* Return the concrete color space underlying this one. */
  122.     /* (Not defined for Pattern spaces.) */
  123.  
  124. #define cs_proc_concrete_space(proc)\
  125.   const gs_color_space *proc(P2(const gs_color_space *,\
  126.                 const gs_imager_state *))
  127. #define cs_concrete_space(pcs, pis)\
  128.   (*(pcs)->type->concrete_space)(pcs, pis)
  129.     cs_proc_concrete_space((*concrete_space));
  130.  
  131.     /*
  132.      * Reduce a color to a concrete color.  A concrete color is one
  133.      * that the device can handle directly (possibly with halftoning):
  134.      * a DeviceGray/RGB/CMYK/Pixel color, or a Separation or DeviceN
  135.      * color that does not use the alternate space.
  136.      * (Not defined for Pattern spaces.)
  137.      */
  138.  
  139. #define cs_proc_concretize_color(proc)\
  140.   int proc(P4(const gs_client_color *, const gs_color_space *,\
  141.     frac *, const gs_imager_state *))
  142. #define cs_concretize_color(pcc, pcs, values, pis)\
  143.   (*(pcs)->type->concretize_color)(pcc, pcs, values, pis)
  144.     cs_proc_concretize_color((*concretize_color));
  145.  
  146.     /* Map a concrete color to a device color. */
  147.     /* (Only defined for concrete color spaces.) */
  148.  
  149. #define cs_proc_remap_concrete_color(proc)\
  150.   int proc(P5(const frac *, gx_device_color *, const gs_imager_state *,\
  151.     gx_device *, gs_color_select_t))
  152.     cs_proc_remap_concrete_color((*remap_concrete_color));
  153.  
  154.     /* Map a color directly to a device color. */
  155.  
  156. #define cs_proc_remap_color(proc)\
  157.   int proc(P6(const gs_client_color *, const gs_color_space *,\
  158.     gx_device_color *, const gs_imager_state *, gx_device *,\
  159.     gs_color_select_t))
  160.     cs_proc_remap_color((*remap_color));
  161.  
  162.     /* Install the color space in a graphics state. */
  163.  
  164. #define cs_proc_install_cspace(proc)\
  165.   int proc(P2(const gs_color_space *, gs_state *))
  166.     cs_proc_install_cspace((*install_cspace));
  167.  
  168.     /* Adjust reference counts of indirect color space components. */
  169.  
  170. #define cs_proc_adjust_cspace_count(proc)\
  171.   void proc(P2(const gs_color_space *, int))
  172. #define cs_adjust_cspace_count(pgs, delta)\
  173.   (*(pgs)->color_space->type->adjust_cspace_count)((pgs)->color_space, delta)
  174.     cs_proc_adjust_cspace_count((*adjust_cspace_count));
  175.  
  176.     /* Adjust reference counts of indirect color components. */
  177.     /*
  178.      * Note: the color space argument may be NULL, which indicates that the
  179.      * caller warrants that any subsidiary colors don't have allocation
  180.      * issues.  This is a hack for an application that needs to be able to
  181.      * release Pattern colors.
  182.      */
  183.  
  184. #define cs_proc_adjust_color_count(proc)\
  185.   void proc(P3(const gs_client_color *, const gs_color_space *, int))
  186. #define cs_adjust_color_count(pgs, delta)\
  187.   (*(pgs)->color_space->type->adjust_color_count)\
  188.     ((pgs)->ccolor, (pgs)->color_space, delta)
  189.     cs_proc_adjust_color_count((*adjust_color_count));
  190.  
  191. /* Adjust both reference counts. */
  192. #define cs_adjust_counts(pgs, delta)\
  193.   (cs_adjust_color_count(pgs, delta), cs_adjust_cspace_count(pgs, delta))
  194.  
  195. };
  196.  
  197. /* Standard color space structure types */
  198. extern_st(st_base_color_space);
  199. #define public_st_base_color_space()    /* in gscspace.c */\
  200.   gs_public_st_simple(st_base_color_space, gs_base_color_space,\
  201.     "gs_base_color_space")
  202. /*extern_st(st_paint_color_space); *//* (not needed) */
  203.  
  204. /* Standard color space procedures */
  205. cs_proc_num_components(gx_num_components_1);
  206. cs_proc_num_components(gx_num_components_3);
  207. cs_proc_num_components(gx_num_components_4);
  208. cs_proc_base_space(gx_no_base_space);
  209. cs_proc_equal(gx_cspace_is_equal);
  210. cs_proc_equal(gx_cspace_not_equal);
  211. cs_proc_init_color(gx_init_paint_1);
  212. cs_proc_init_color(gx_init_paint_3);
  213. cs_proc_init_color(gx_init_paint_4);
  214. cs_proc_restrict_color(gx_restrict01_paint_1);
  215. cs_proc_restrict_color(gx_restrict01_paint_3);
  216. cs_proc_restrict_color(gx_restrict01_paint_4);
  217. cs_proc_concrete_space(gx_no_concrete_space);
  218. cs_proc_concrete_space(gx_same_concrete_space);
  219. cs_proc_concretize_color(gx_no_concretize_color);
  220. cs_proc_remap_color(gx_default_remap_color);
  221. cs_proc_install_cspace(gx_no_install_cspace);
  222. cs_proc_adjust_cspace_count(gx_no_adjust_cspace_count);
  223. cs_proc_adjust_color_count(gx_no_adjust_color_count);
  224.  
  225. /*
  226.  * Define the implementation procedures for the standard device color
  227.  * spaces.  These are implemented in gxcmap.c.
  228.  */
  229. cs_proc_remap_color(gx_remap_DeviceGray);
  230. cs_proc_concretize_color(gx_concretize_DeviceGray);
  231. cs_proc_remap_concrete_color(gx_remap_concrete_DGray);
  232. cs_proc_remap_color(gx_remap_DeviceRGB);
  233. cs_proc_concretize_color(gx_concretize_DeviceRGB);
  234. cs_proc_remap_concrete_color(gx_remap_concrete_DRGB);
  235. cs_proc_remap_color(gx_remap_DeviceCMYK);
  236. cs_proc_concretize_color(gx_concretize_DeviceCMYK);
  237. cs_proc_remap_concrete_color(gx_remap_concrete_DCMYK);
  238.  
  239. /* Define the allocator type for color spaces. */
  240. extern_st(st_color_space);
  241.  
  242. /*
  243.  * Initialize the type and memory fields of a color space, possibly
  244.  * allocating it first.  This is only used by color space implementations.
  245.  */
  246. void gs_cspace_init(P3(gs_color_space *pcs,
  247.                const gs_color_space_type *pcstype,
  248.                gs_memory_t *mem));
  249. int gs_cspace_alloc(P3(gs_color_space **ppcspace,
  250.                const gs_color_space_type *pcstype,
  251.                gs_memory_t *mem));
  252.  
  253. #endif /* gxcspace_INCLUDED */
  254.